function currentPage(xhr, status, args) {
	setTimeout(function() {
		window.location = args.view;
	}, 500);
}

function currentPage(view) {
	setTimeout(function() {
		window.location = view;
	}, 500);
}
function showContent(divName, url){
	var result = syncAjaxLoadText(url,true);
	$("#" + divName).html(result);
	$(window).trigger("loadFinish");
}
function syncAjaxLoadText(params,globalParam) {
	var url;
	var ajaxParams = {};
	if (typeof params == "object") {
		url = params.url;
		ajaxParams = params.params;
	} else {
		url = params;
	}
	var rq = $.ajax({
		type: "POST",
		url: url,
		async: false,
		data: ajaxParams,
		global: globalParam?globalParam:true,
		success: function (json, status, rq) {
			if (!ajaxFailJson(json)) {
				rq.data = json;
			}else{
				rq.data = getAjaxFailJson(json);
			}
		},
		dataType: "text"
	});
	handleErrorPage(rq);
	return rq.data;
}
function ajaxFailJson(json){
	return (json[0] == "[" || json[0] == "{");
}
function handleErrorPage(ajaxRequest){
	if(ajaxRequest.data == undefined){
		$errorContent=$(ajaxRequest.responseText);
		if($errorContent.hasClass("transversal-error")){
			$target = $("#tab0").length == 0?$("#content"):$("#tab0");
			$target.empty();
			$target.append($errorContent);
			throw "_";
		}
	}
}

function logout(xhr, status, args) {
    setTimeout(function() {
      window.location = '../login.xhtml';
    }, 500);
  }